"""
2"图形分为三角形(三条边)，长方形(长和宽)和圆形(半径)
都有计算周长和面积的方法。

要求：抽象出图像父类，并定义三角形、长方形、圆形子类，
计算各种图形的面积和周长(父类中定义计算面积和周长的抽象方法)
"""

class picture:
    def __init__(self,length):
        self.length = length


class tri(picture):
    def __init__(self,length,wide,high):
        super().__init__(length)
        self.wide = wide
        self.high = high

    def length_area(self):
        L = self.length + self.high + self.wide
        A = ((L / 2) * ((L / 2) - self.length) * ((L / 2) - self.high) * ((L / 2) - self.wide)) ** 0.5
        return L, A

class rectangle(picture):
    def __init__(self,length,wide):
        super().__init__(length,)
        self.wide = wide

    def length_area(self):
        L = (self.length + self.wide) * 2
        A = self.length * self.wide
        return  L, A

class circle(picture):
    def __init__(self,length):
        super().__init__(length)

    def length_area(self):
        L = self.length * 2 *3.14
        A = self.length ** 2 *3.14
        return L, A

if __name__ == '__main__':
    B = tri(3,3,3)
    C = rectangle(3,3)
    D = circle(3)
    print(B.length_area())
    print(C.length_area())
    print(D.length_area())